package com.itheima.test;

import java.util.Random;

/**
 * @Author 王加鑫
 * @Date 2021/4/19 18:04
 * @Version 1.0
 * 产生10个不重复的随机数
 */
public class RandomTest02 {
    public static void main(String[] args) {
        Random random = new Random();
        int[] arrayNum = new int[10];
        for (int i = 0; i <arrayNum.length; i++) {
            arrayNum[i] = random.nextInt(10);
            for (int j = 0; j <i; j++) {
                while (arrayNum[i] == arrayNum[j]){
                    i--;
                }
            }
        }

        for (int i = 0; i <arrayNum.length ; i++) {
            System.out.println(arrayNum[i]);
        }
    }
}
